#include <iostream>
#include <string>
using namespace std;

class Solution
{
public:
    int removeDuplicates(int A[], int n)
    {
        if(n==0)
            return 0;
        int i=0;
        for(int j=0; j<n-1; ++j)
            {
                if(A[j]!=A[j+1])
                    A[i++]=A[j];
            }
        if(A[n-1]!=A[i])
            A[i]=A[n-1];
        return i+1;
    }
};

int main()
{
    Solution s;
    int arr[]= {1,1,2,2,2,3,3,4,4,5,5,6,8};
    int len=sizeof(arr)/sizeof(int);
    int n=s.removeDuplicates(arr,len);
    for(int i=0; i<n; ++i)
        {
            cout<<arr[i]<<",";
        }

}